<?php
/*
 * @Author: your name
 * @Date: 2022-01-20 16:26:40
 * @LastEditTime: 2022-03-02 22:01:29
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /nlog/app/Models/crm_model/CrmLinkman.php
 */

namespace App\Models\crm_model;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class CrmLinkmanAttachment extends Model
{
    use HasFactory;
    static string $tableName = 'crm_linkman_attachment';
    
   
    public static function  list($whereStr = '' ,$limitStr = ''){
        // echo " SELECT * FROM `crm_linkman_attachment` WHERE `delete_time` is null ".$whereStr."  ORDER BY `id` DESC ".$limitStr;
        return DB::select(" SELECT * FROM `crm_linkman_attachment` WHERE `delete_time` is null ".$whereStr."  ORDER BY `id` DESC ".$limitStr);
    }

    public static function   insertUpdated($formDataStr){
        return   DB::update("INSERT INTO ".self::$tableName." ( ".$formDataStr['keyStr'].",update_time,create_time) VALUES ( ".$formDataStr['valStr'].",NOW(),NOW() ) ON DUPLICATE KEY UPDATE ".$formDataStr['updateStr'].",update_time = now() ");
     }

     public static function insert($formData){
        return DB::table(self::$tableName)->insert($formData);

     }

     public static function edit($formData,$id){
         return DB::table(self::$tableName)->where(['id'=>$id])->update($formData);
     }

   
   
}

